package org.anderground.editor.gui.menubar;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JSeparator;

import org.anderground.editor.edits.EditsManager;
import org.anderground.editor.gui.MainWindow;

/**
 * 
 * @author Ilya Shurigyn
 * 
 */
public class EditMenu extends JMenu {
	public EditMenu(MainWindow parent) {
		super("Edit");

		add(new RedoMenuItem());
		add(new UndoMenuItem());
		// ---
		add(new JSeparator());
		add(new AddDrawerMenuItem());
		add(new ToolsMenu());

	}
}

/**
 * Undo item for editor menu
 * 
 * @author Ilya Shurigyn
 * 
 */
class UndoMenuItem extends JMenuItem {
	public UndoMenuItem() {
		super("Undo");
		addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				if (EditsManager.getInstance().canUndo())
					EditsManager.getInstance().undo();
			}

		});
	}
}

/**
 * Redo item for editor menu
 * 
 * @author Ilya Shurigyn
 * 
 */
class RedoMenuItem extends JMenuItem {
	public RedoMenuItem() {
		super("Redo");
		addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO
				/* EditorModel.getInstance().redo(); */
			}

		});
	}
}
